package resp

import (
	"github.com/gin-gonic/gin"
)

type resp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data,omitempty"`
}

func OK(ctx *gin.Context, msg string, data any) {
	ctx.JSON(200, resp{Code: 0, Msg: msg, Data: data})
}

func OKWithoutData(ctx *gin.Context, msg string) {
	ctx.JSON(200, resp{Code: 0, Msg: msg})
}

func OKPage(ctx *gin.Context, total, page, pageSize int64, data any) {
	ctx.JSON(200, resp{Code: 0, Msg: "ok", Data: gin.H{"total": total, "page": page, "pageSize": pageSize, "list": data}})
}
